import { algoTestApi } from '@/services'
import { waitLoading } from '@/utils'

const getRecordDownloadUrl = async (recordId: string) => {
  const { data } = await algoTestApi.getRecordDownloadUrl(recordId)()
  window.open(data)
  return data
}

export const downloadTaskRecord = async (recordId: string) => {
  waitLoading<ResponseData<string>>(getRecordDownloadUrl(recordId), {
    loadingText: '数据准备中,请耐心等待...',
    errorText: '文件下载失败'
  })
}
